package org.jeecg.modules.user.member.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xkcoding.http.util.StringUtil;
import lombok.extern.slf4j.Slf4j;
import me.zhyd.oauth.utils.UuidUtils;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.api.MemberAPI;
import org.jeecg.common.api.dto.MemberDTO;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.system.util.JwtUtil;
import org.jeecg.common.util.PasswordUtil;
import org.jeecg.common.util.RedisUtil;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.bicycle.order.entity.BikeVehicleOrder;
import org.jeecg.modules.bicycle.order.service.IBikeVehicleOrderService;
import org.jeecg.modules.constant.BikeConstant;
import org.jeecg.modules.param.charge.entity.BikeMemberUserCharge;
import org.jeecg.modules.param.charge.service.IBikeMemberUserChargeService;
import org.jeecg.modules.param.member.entity.BikeMemberUser;
import org.jeecg.modules.param.member.mapper.BikeMemberUserMapper;
import org.jeecg.modules.param.member.service.IBikeMemberUserService;
import org.jeecg.modules.param.spend.entity.BikeMemberUserSpend;
import org.jeecg.modules.param.spend.service.IBikeMemberUserSpendService;
import org.jeecg.modules.user.code.entity.SmsCode;
import org.jeecg.modules.user.code.service.SmsCodeService;
import org.jeecg.modules.user.member.dto.*;
import org.jeecg.modules.user.member.entity.Member;
import org.jeecg.modules.user.member.mapper.MemberMapper;
import org.jeecg.modules.user.member.service.MemberService;
import org.jeecg.modules.user.member.service.PayService;
import org.jeecg.modules.user.pay.dto.AlipayReq;
import org.jeecg.modules.user.pay.dto.PayReq;
import org.jeecg.modules.user.pay.entity.BikeAliOrderPay;
import org.jeecg.modules.user.pay.service.IBikeAliOrderPayService;
import org.jeecg.modules.user.withhold.entity.BikeMemberWithhold;
import org.jeecg.modules.user.withhold.mapper.BikeMemberWithholdMapper;
import org.jeecg.modules.user.withhold.service.IBikeMemberWithholdService;
import org.jeecg.modules.utils.AliAuthUtils;
import org.jeecg.modules.utils.AliPayKit;
import org.jeecg.modules.utils.BikeResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * @Description: bike_pile
 * @Author: jeecg-boot
 * @Date:   2021-05-19
 * @Version: V1.0
 */
@Slf4j
@Service
public class PayServiceImpl implements PayService {

    @Autowired
    private IBikeAliOrderPayService bikeAliOrderPayService;
    @Autowired
    private IBikeMemberUserChargeService bikeMemberUserChargeService;
    @Autowired
    private IBikeMemberUserService bikeMemberUserService;
    @Autowired
    private IBikeVehicleOrderService bikeVehicleOrderService;
    @Autowired
    private IBikeMemberUserSpendService bikeMemberUserSpendService;
    @Autowired
    private IBikeMemberWithholdService bikeMemberWithholdService;
    @Autowired
    private BikeMemberWithholdMapper bikeMemberWithholdMapper;
    @Autowired
    private MemberAPI memberAPI;

    @Override
    public Map<String, String> recharge(AlipayReq alipayReq, HttpServletRequest request) {
        String token = request.getHeader(CommonConstant.X_ACCESS_TOKEN);
        String username = JwtUtil.getUsername(token);
        MemberDTO member = memberAPI.getMember(username);
        Map<String, String> map = new HashMap<String, String>();
        map.put("body", "余额充值");
        map.put("subject", "余额充值");
        map.put("outTradeNo", UuidUtils.getUUID());
        map.put("totalAmount", alipayReq.getTotalAmount());
        map.put("notifyUrl", "/bike/alipay/buyVipByAlipay");


        BikeMemberWithhold bikeMemberWithhold = bikeMemberWithholdMapper.selectOne(
                new QueryWrapper<BikeMemberWithhold>()
                        .eq("external_agreement_no", username).eq("status","NORMAL")
        );

        if (bikeMemberWithhold!=null){
            map.put("id",bikeMemberWithhold.getId());
            map.put("personalProductCode",bikeMemberWithhold.getPersonalProductCode());
            map.put("signScene",bikeMemberWithhold.getSignScene());
            map.put("externalAgreementNo",bikeMemberWithhold.getExternalAgreementNo());
            map.put("externalLogonId",bikeMemberWithhold.getExternalLogonId());
        }

        BikeAliOrderPay bikeAliOrderPay = new BikeAliOrderPay();
        bikeAliOrderPay.setBody(map.get("body"));
        bikeAliOrderPay.setOutTradeNo(map.get("outTradeNo"));
        bikeAliOrderPay.setUserId(member.getId());
        bikeAliOrderPay.setTradeStatus("WAIT_BUYER_PAY");
        bikeAliOrderPay.setSubject(map.get("subject"));
        bikeAliOrderPayService.save(bikeAliOrderPay);
        return map;
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Map<String, String> recharge(PayReq payReq, HttpServletRequest request) {
        String token = request.getHeader(CommonConstant.X_ACCESS_TOKEN);
        String username = JwtUtil.getUsername(token);
        MemberDTO member = memberAPI.getMember(username);
        Map<String, String> map = new HashMap<String, String>();

        //公共参数
        BikeMemberUser bikeMemberUser = bikeMemberUserService.getById(member.getId());
        BikeMemberUser bm = new BikeMemberUser();
        QueryWrapper qw = new QueryWrapper();
        qw.eq("id", bikeMemberUser.getId());
        BikeAliOrderPay bikeAliOrderPay = new BikeAliOrderPay();

        //获取车辆借还记录未支付的订单
        QueryWrapper queryWrapper1 = new QueryWrapper();
        queryWrapper1.eq("pick_user",member.getId());
        queryWrapper1.eq("is_pay","0");
        BikeVehicleOrder bikeVehicleOrder = bikeVehicleOrderService.getOne(queryWrapper1);
        if (bikeVehicleOrder.getBillStatus().equals("2")){
            map.put("code", "0");
            map.put("message", "免单审批中，请勿支付！");
            return map;
        }
        //应该支付费用
        BigDecimal payCost = bikeVehicleOrder.getPayCost();
        //直接余额支付
        if (payReq.getType() == 2) {
            if (bikeMemberUser.getBalance().compareTo(new BigDecimal(payReq.getTotalAmount())) < 0) {
                map.put("code", "0");
                map.put("message", "余额不足");
                return map;
            }
            //余额支付
            bm.setBalance(bikeMemberUser.getBalance().subtract(bikeVehicleOrder.getPayCost()));
            bikeMemberUserService.update(bm,qw);

            //支付完成修改车辆借还记录的状态
            BikeVehicleOrder bikeVehicleOrder1 = new BikeVehicleOrder();
            bikeVehicleOrder1.setPayActual(bikeVehicleOrder.getPayCost());
            bikeVehicleOrder1.setIsPay("1");
            bikeVehicleOrder1.setRideStatus("5");
            bikeVehicleOrder1.setBillStatus("4");
            bikeVehicleOrderService.update(bikeVehicleOrder1,queryWrapper1);


            BikeMemberUserSpend bikeMemberUserSpend = new BikeMemberUserSpend();
            bikeMemberUserSpend.setOrderId(bikeVehicleOrder.getId());
            bikeMemberUserSpend.setUserId(member.getId());
            bikeMemberUserSpend.setSpendAmount(bikeVehicleOrder.getPayCost());
            bikeMemberUserSpend.setBalanceEnd(bikeMemberUser.getBalance().subtract(bikeVehicleOrder.getPayCost()));
            bikeMemberUserSpend.setSpendType("1");
            bikeMemberUserSpend.setMemo("单车骑行费用");
            bikeMemberUserSpendService.save(bikeMemberUserSpend);

            map.put("code", "1");
            map.put("message", "支付成功");
            return map;

        } else if (payReq.getType() == 1) {  //支付宝支付

            map.put("body", "还车付费");
            map.put("subject", "还车付费");
            map.put("outTradeNo", UuidUtils.getUUID());
            map.put("totalAmount", payReq.getTotalAmount());
            map.put("notifyUrl", "/bike/alipay/payment");


            bikeAliOrderPay.setBody(map.get("body"));
            bikeAliOrderPay.setOutTradeNo(map.get("outTradeNo"));
            bikeAliOrderPay.setUserId(member.getId());
            bikeAliOrderPay.setTradeStatus("WAIT_BUYER_PAY");
            bikeAliOrderPay.setSubject(map.get("subject"));
            bikeAliOrderPayService.save(bikeAliOrderPay);
            return AliPayKit.pay(map);
        } else {  //组合支付
            //判断余额支付金额是否大于应支付的金额 如果大于 直接支付 不需要跳转支付宝支付
            if (bikeVehicleOrder.getPayCost().compareTo(bikeMemberUser.getBalance()) == -1 || bikeVehicleOrder.getPayCost().compareTo(bikeMemberUser.getBalance()) == 0) {
                bm.setBalance(bikeMemberUser.getBalance().subtract(bikeVehicleOrder.getPayCost()));
                bikeMemberUserService.update(bm, qw);
                //骑行记录
                BikeVehicleOrder bikeVehicleOrder1 = new BikeVehicleOrder();
                bikeVehicleOrder1.setPayActual(bikeVehicleOrder.getPayCost());
                bikeVehicleOrder1.setIsPay("1");
                bikeVehicleOrder1.setRideStatus("5");
                bikeVehicleOrder1.setBillStatus("4");
                bikeVehicleOrderService.update(bikeVehicleOrder1, queryWrapper1);
                //消费记录
                BikeMemberUserSpend bikeMemberUserSpend = new BikeMemberUserSpend();
                bikeMemberUserSpend.setOrderId(bikeVehicleOrder.getId());
                bikeMemberUserSpend.setUserId(member.getId());
                bikeMemberUserSpend.setSpendAmount(bikeVehicleOrder.getPayCost());
                bikeMemberUserSpend.setBalanceEnd(bikeMemberUser.getBalance().subtract(bikeVehicleOrder.getPayCost()));
                bikeMemberUserSpend.setSpendType("3");
                bikeMemberUserSpend.setMemo("单车骑行费用");
                bikeMemberUserSpendService.save(bikeMemberUserSpend);
                map.put("code", "1");
                map.put("message", "支付成功");
                return map;
            } else {
                //支付宝应付
                BigDecimal bigDecimal = new BigDecimal(String.valueOf(bikeVehicleOrder.getPayCost().subtract(bikeMemberUser.getBalance())));
                DecimalFormat df = new DecimalFormat("0.00");
                String totalAmount = df.format(bigDecimal);

                //先支付余额  在调支付宝支付
                map.put("body", "还车付费");
                map.put("subject", "还车付费");
                map.put("outTradeNo", UuidUtils.getUUID());
                map.put("totalAmount", totalAmount);
                map.put("notifyUrl", "/bike/alipay/mixedPay");

                //阿里表
                bikeAliOrderPay.setBody(map.get("body"));
                bikeAliOrderPay.setOutTradeNo(map.get("outTradeNo"));
                bikeAliOrderPay.setUserId(member.getId());
                bikeAliOrderPay.setTradeStatus("WAIT_BUYER_PAY");
                bikeAliOrderPay.setSubject(map.get("subject"));
                bikeAliOrderPayService.save(bikeAliOrderPay);
                return AliPayKit.pay(map);
            }
        }
    }

    @Override
    public String settleInByAlipay(HttpServletRequest request) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd HH:mm:ss");
        if (!AliPayKit.verify(request))   return "fail";
        String tradeStatus = request.getParameter("trade_status"); // 交易状态
        String outTradeNo = request.getParameter("out_trade_no"); // 商户订单号
        String tradeNo = request.getParameter("trade_no"); // 支付宝订单号
        String totalAmount = request.getParameter("total_amount");// 付款金额
        String sellerId = request.getParameter("seller_id");
        String buyerId = request.getParameter("buyer_id");
        //查询充值记录
        QueryWrapper queryWrapper =new QueryWrapper();
        queryWrapper.eq("out_trade_no",outTradeNo);
        BikeAliOrderPay play= bikeAliOrderPayService.getOne(queryWrapper);
        //获取用户信息
        BikeMemberUser memberUser= bikeMemberUserService.getById(play.getUserId());

        //支付宝支付成功
        if (tradeStatus.equals("TRADE_SUCCESS")){
            //修改用户金额
            QueryWrapper qwe = new QueryWrapper();
            BikeMemberUser bikeMemberUser = new BikeMemberUser();
            qwe.eq("id",play.getUserId());
            bikeMemberUser.setBalance(memberUser.getBalance().add(new BigDecimal(totalAmount)));
            bikeMemberUserService.update(bikeMemberUser,qwe);
            //添加充值记录
            BikeMemberUserCharge bikeMemberUserCharge = new BikeMemberUserCharge();
            bikeMemberUserCharge.setUserId(play.getUserId());
            bikeMemberUserCharge.setOutTradeNo(outTradeNo);
            bikeMemberUserCharge.setChargeAmount(new BigDecimal(totalAmount));
            bikeMemberUserCharge.setChargeType("2");
            bikeMemberUserCharge.setChargeCanal("3");
            bikeMemberUserCharge.setCreateTime(new Date());
            bikeMemberUserCharge.setUserName(bikeMemberUser.getName());
            bikeMemberUserCharge.setBalanceEnd(memberUser.getBalance().add(new BigDecimal(totalAmount)));
            bikeMemberUserCharge.setMemo("账户充值");
            bikeMemberUserCharge.setIsFullRefund(BikeConstant.y_n_no);
            bikeMemberUserChargeService.save(bikeMemberUserCharge);
            BikeMemberUserSpend bikeMemberUserSpend = new BikeMemberUserSpend();
        }
        try {
            BikeAliOrderPay bikeAliOrderPay = new BikeAliOrderPay();
            bikeAliOrderPay.setTradeNo(tradeNo);
            bikeAliOrderPay.setSellerId(sellerId);
            bikeAliOrderPay.setTotalAmount(totalAmount);
            bikeAliOrderPay.setTradeStatus(tradeStatus);
            bikeAliOrderPay.setGmtCreate(sdf.parse(request.getParameter("gmt_create")));
            bikeAliOrderPay.setGmtPayment(sdf.parse(request.getParameter("gmt_payment")));
            bikeAliOrderPay.setBuyerId(buyerId);
            bikeAliOrderPay.setBuyerLogonId(request.getParameter("buyer_logon_id"));
            QueryWrapper qw = new QueryWrapper();
            qw.eq("out_trade_no",outTradeNo);
            boolean  flag =bikeAliOrderPayService.update(bikeAliOrderPay,qw);
            if (!flag){
                return "fail";
            }
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return "success";
    }

    /**
     * 支付宝支付回调
     * */
    @Override
    public String payment(HttpServletRequest request) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd HH:mm:ss");
        if (!AliPayKit.verify(request))   return "fail";
        String tradeStatus = request.getParameter("trade_status"); // 交易状态
        String outTradeNo = request.getParameter("out_trade_no"); // 商户订单号
        String tradeNo = request.getParameter("trade_no"); // 支付宝订单号
        String totalAmount = request.getParameter("total_amount");// 付款金额
        String sellerId = request.getParameter("seller_id");
        String buyerId = request.getParameter("buyer_id");
        //查询充值记录
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("out_trade_no", outTradeNo);
        BikeAliOrderPay play = bikeAliOrderPayService.getOne(queryWrapper);

        //支付宝支付成功
        if (tradeStatus.equals("TRADE_SUCCESS")) {
            //骑行记录
            QueryWrapper queryWrapper1 = new QueryWrapper();
            queryWrapper1.eq("pick_user", play.getUserId());
            queryWrapper1.eq("is_pay", "0");
            BikeVehicleOrder bikeVehicleOrder = bikeVehicleOrderService.getOne(queryWrapper1);
            //if (bikeVehicleOrder.getPayCost().add(new BigDecimal(totalAmount)).compareTo(bikeVehicleOrder.getPayCost()) != -1) {
            BigDecimal spendAmount = bikeVehicleOrder.getPayCost().subtract(new BigDecimal(totalAmount));
            BigDecimal aliAmount = new BigDecimal(totalAmount);
            BikeVehicleOrder bikeVehicleOrder1 = new BikeVehicleOrder();
            bikeVehicleOrder1.setPayActual(spendAmount.add(aliAmount));
            bikeVehicleOrder1.setIsPay("1");
            bikeVehicleOrder1.setRideStatus("5");
            bikeVehicleOrder1.setBillStatus("4");
            bikeVehicleOrderService.update(bikeVehicleOrder1, queryWrapper1);
            //}
            //消费记录
            BikeMemberUserSpend bikeMemberUserSpend = new BikeMemberUserSpend();
            bikeMemberUserSpend.setOrderId(bikeVehicleOrder.getId());
            bikeMemberUserSpend.setUserId(play.getUserId());
            bikeMemberUserSpend.setSpendAmount(spendAmount);
            bikeMemberUserSpend.setBalanceEnd(new BigDecimal(0));
            if (spendAmount.compareTo(new BigDecimal(0))==0){
                bikeMemberUserSpend.setAliAmount(aliAmount);
                bikeMemberUserSpend.setSpendAmount(spendAmount);
                bikeMemberUserSpend.setSpendType("2");
            }else{
                bikeMemberUserSpend.setAliAmount(aliAmount);
                bikeMemberUserSpend.setSpendAmount(spendAmount);
                bikeMemberUserSpend.setSpendType("3");
            }
            bikeMemberUserSpend.setOutTradeNo(outTradeNo);
            bikeMemberUserSpend.setAliUserId(sellerId);
            bikeMemberUserSpend.setAliOrderId(tradeNo);
            bikeMemberUserSpend.setMemo("单车骑行费用");
            bikeMemberUserSpendService.save(bikeMemberUserSpend);
        }

        //修改用户金额
        try {
            BikeAliOrderPay bikeAliOrderPay = new BikeAliOrderPay();
            bikeAliOrderPay.setTradeNo(tradeNo);
            bikeAliOrderPay.setSellerId(sellerId);
            bikeAliOrderPay.setTotalAmount(totalAmount);
            bikeAliOrderPay.setTradeStatus(tradeStatus);
            bikeAliOrderPay.setGmtCreate(sdf.parse(request.getParameter("gmt_create")));
            bikeAliOrderPay.setGmtPayment(sdf.parse(request.getParameter("gmt_payment")));
            bikeAliOrderPay.setBuyerId(buyerId);
            bikeAliOrderPay.setBuyerLogonId(request.getParameter("buyer_logon_id"));
            QueryWrapper qw = new QueryWrapper();
            qw.eq("out_trade_no", outTradeNo);
            boolean flag = bikeAliOrderPayService.update(bikeAliOrderPay, qw);
            if (!flag) {
                return "fail";
            }
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return "success";
    }

    /**
     * 组合支付回调
     * */
    @Override
    public String mixedPay(HttpServletRequest request) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd HH:mm:ss");
        if (!AliPayKit.verify(request))   return "fail";
        String tradeStatus = request.getParameter("trade_status"); // 交易状态
        String outTradeNo = request.getParameter("out_trade_no"); // 商户订单号
        String tradeNo = request.getParameter("trade_no"); // 支付宝订单号
        String totalAmount = request.getParameter("total_amount");// 付款金额
        String sellerId = request.getParameter("seller_id");
        String buyerId = request.getParameter("buyer_id");
        //查询充值记录
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("out_trade_no", outTradeNo);
        BikeAliOrderPay play = bikeAliOrderPayService.getOne(queryWrapper);

        //支付宝支付成功
        if (tradeStatus.equals("TRADE_SUCCESS")) {
            log.info("组合付款成功");
            //修改用户金额
            BikeMemberUser memberUser = new BikeMemberUser();
            memberUser.setId(play.getUserId());
            memberUser.setBalance(new BigDecimal(0));
            bikeMemberUserService.updateById(memberUser);

            //骑行记录
            QueryWrapper queryWrapper1 = new QueryWrapper();
            queryWrapper1.eq("pick_user", play.getUserId());
            queryWrapper1.eq("is_pay", "0");
            BikeVehicleOrder bikeVehicleOrder = bikeVehicleOrderService.getOne(queryWrapper1);
            //if (bikeVehicleOrder.getPayCost().add(new BigDecimal(totalAmount)).compareTo(bikeVehicleOrder.getPayCost()) != -1) {
            BigDecimal spendAmount = bikeVehicleOrder.getPayCost().subtract(new BigDecimal(totalAmount));
            BigDecimal aliAmount = new BigDecimal(totalAmount);
            BikeVehicleOrder bikeVehicleOrder1 = new BikeVehicleOrder();
            bikeVehicleOrder1.setPayActual(spendAmount.add(aliAmount));
            bikeVehicleOrder1.setIsPay("1");
            bikeVehicleOrder1.setRideStatus("5");
            bikeVehicleOrder1.setBillStatus("4");
            bikeVehicleOrderService.update(bikeVehicleOrder1, queryWrapper1);
            //}
            //消费记录
            BikeMemberUserSpend bikeMemberUserSpend = new BikeMemberUserSpend();
            bikeMemberUserSpend.setOrderId(bikeVehicleOrder.getId());
            bikeMemberUserSpend.setUserId(play.getUserId());
            bikeMemberUserSpend.setSpendAmount(spendAmount);
            bikeMemberUserSpend.setBalanceEnd(new BigDecimal(0));
            if (spendAmount.compareTo(new BigDecimal(0))==0){
                bikeMemberUserSpend.setAliAmount(aliAmount);
                bikeMemberUserSpend.setSpendAmount(spendAmount);
                bikeMemberUserSpend.setSpendType("2");
            }else{
                bikeMemberUserSpend.setAliAmount(aliAmount);
                bikeMemberUserSpend.setSpendAmount(spendAmount);
                bikeMemberUserSpend.setSpendType("3");
            }
            bikeMemberUserSpend.setOutTradeNo(outTradeNo);
            bikeMemberUserSpend.setAliUserId(sellerId);
            bikeMemberUserSpend.setAliOrderId(tradeNo);
            bikeMemberUserSpend.setMemo("单车骑行费用");
            bikeMemberUserSpendService.save(bikeMemberUserSpend);

        }

        try {
            BikeAliOrderPay bikeAliOrderPay = new BikeAliOrderPay();
            bikeAliOrderPay.setTradeNo(tradeNo);
            bikeAliOrderPay.setSellerId(sellerId);
            bikeAliOrderPay.setTotalAmount(totalAmount);
            bikeAliOrderPay.setTradeStatus(tradeStatus);
            bikeAliOrderPay.setGmtCreate(sdf.parse(request.getParameter("gmt_create")));
            bikeAliOrderPay.setGmtPayment(sdf.parse(request.getParameter("gmt_payment")));
            bikeAliOrderPay.setBuyerId(buyerId);
            bikeAliOrderPay.setBuyerLogonId(request.getParameter("buyer_logon_id"));
            QueryWrapper qw = new QueryWrapper();
            qw.eq("out_trade_no", outTradeNo);
            boolean flag = bikeAliOrderPayService.update(bikeAliOrderPay, qw);
            if (!flag) {
                return "fail";
            }
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return "success";
    }
}
